package excelGUI.dataProc;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.util.CellReference;

public class DataStub {
	private Path mPath;
	private TextLabelListener mListener1;
	private ArrayList list = new ArrayList();

	public DataStub() {
	}

	public interface TextLabelListener {
		void setText(String text);
	}

	public void addListener(TextLabelListener mListener1) {
		this.mListener1 = mListener1;
	}

	public void addBox() {
	}

	public void importFile(File file) {
		String path = file.getPath();
		mListener1.setText(path);
		insertExcel(file);
		
	}
	
	private void insertExcel(File file){
		Workbook b = null;
		try {
			b = WorkbookFactory.create(new FileInputStream(file));
		} catch (InvalidFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if(b == null)return;
		int sheetNumber = b.getNumberOfSheets();
		mListener1.setText("sheetNumber"+sheetNumber);
	}
}
